package com.edooteach.tencent.handle.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import com.demo2do.core.wechat.entity.token.Token;
import com.edooteach.tencent.CacheKeys;
import com.edooteach.tencent.accessor.CorpTokenAssessor;
import com.edooteach.tencent.handle.CorpTokenHandler;

/**
 * 
 * @author mohanlan
 *
 */
@Component("corpTokenHandler")
public class CorpTokenHandlerImpl implements CorpTokenHandler {
  
  private static final Logger logger = LoggerFactory.getLogger(CorpTokenHandler.class);
  
  @Autowired
  private CorpTokenAssessor corpTokenAssessor;

  /*
   * (non-Javadoc)
   * @see com.edooteach.tencent.handle.WeappTokenHandler#requestAccessToken()
   */
  @Cacheable(CacheKeys.CorpCache.ACCESS_TOKEN)
  public Token requestAccessToken() {
      logger.trace("#requestAccessToken - Request access_token from tencent at {}.", System.currentTimeMillis());
      return corpTokenAssessor.requestAccessToken();
  }

}
